package org.oos.dao.impl;

import static org.oos.ApiUrlProvider.SocialActivity;

import org.oos.atom.ActivityFeed;
import org.oos.atom.entries.ActivityEntry;
import org.oos.atom.entries.impl.ActivityEntryImpl;
import org.oos.atom.impl.ActivityFeedImpl;
import org.oos.dao.SocialActivityDao;
import org.oos.dao.lists.impl.ReadOnlyDynamicList;

import com.google.api.client.http.GenericUrl;

public class SocialActivityDaoImpl extends
		ReadOnlyAbstractDao<ActivityEntry, ActivityFeed<ActivityEntry>>
		implements SocialActivityDao {

	private static final long serialVersionUID = 1646316835760754819L;
	public String userSlug;

	public SocialActivityDaoImpl() {
		super(ActivityFeedImpl.class, ActivityEntryImpl.class);
	}

	@Override
	public GenericUrl getFeedUrl() {
		if (userSlug != null) {
			return SocialActivity.getUrl(userSlug);
		} else {
			throw new IllegalStateException("There must be a slug");
		}
	}

	@Override
	public void setUserSlug(String userSlug) {
		this.userSlug = userSlug;
	}

	@SuppressWarnings("unchecked")
	@Override
	protected ReadOnlyDynamicList<ActivityEntry, ActivityFeed<ActivityEntry>> getList(
			ActivityFeed feed) {
		return new ReadOnlyDynamicList<ActivityEntry, ActivityFeed<ActivityEntry>>(
				this, feed);
	}

}
